/**********************************************************************
 * FILE : CmdProto.java
 * CREATE DATE : 2011-11-25
 * DESCRIPTION :
 *		
 *      
 * CHANGE HISTORY LOG
 *---------------------------------------------------------------------
 * NO.|    DATE    |     NAME     |     REASON     | DESCRIPTION
 *---------------------------------------------------------------------
 * 1  | 2011-11-25 |  Sting  |    创建草稿版本
 *---------------------------------------------------------------------              
 **********************************************************************
 */
package com.sgm.de.benchmark;

import com.sgm.de.benchmark.act.GlobalAct;
import com.sgm.de.benchmark.act.IAct;

public class Cmd {
    public String act = null;
    public Object[] args = null;

    public Cmd() {
    }

    public Cmd(String actor, Object... args) {
        this.act = actor;
        this.args = args;
    }

    /**
     * TODO 这里描述每个参数变量的用途和意义，以及返回结果对象的作用描述
     * 
     */
    public IAct guessAct() {
        try {
            String name = act.substring(0, 1).toUpperCase() + act.substring(1);
            IAct act = (IAct) Class.forName("com.sgm.de.benchmark.act." + name).newInstance();
            act.setAct(this.act);
            act.setArgs(this.args);
            return act;
        } catch (Exception e) {
            System.err.println("actor [" + act + "] not found");
            System.err.println(e.getMessage());
            return new GlobalAct(act, args);
        }
    }

}